﻿
@{
    ViewBag.Title = "Good";
    Layout = "~/Areas/Admin/Views/Shared/AdminLayout.cshtml";
}

<style>
    .hdlist{width: 300px;height: 200px;border:1px solid #cccccc;float: left;margin:10px;}
    .hdlist img{width: 300px;height: 150px;}
    .ope{color: red;}
</style>

<div class="searchpanel">
    <div class="seatchtool">
        <div class="operationtool">
            <a id="add">增加</a>
        </div>
        <div class="operationsearch">
           
        </div>
    </div>
</div>
<div style="width: 100%;height: auto;overflow: hidden;font-size: 12px;" id="list">
    
</div>
<script>
    $(function() {
        getlist();
    });
    $("#add").click(function() {
        location.href = "@Url.Action("Window")";
    });

    function getlist() {
        $.post("@Url.Action("GetList")", function(data) {
            var obj = JSON.parse(data);
            var str = "";
            for (var i = 0; i < obj.length; i++) {
                str += "<div class=\"hdlist\">" +
                    "<img src=\"" + obj[i].Img + "\" />" +
                    "<a href=\"" + obj[i].Url + "\" target=\"_blank\">" + obj[i].Url + "</a>" +
                    "<div class=\"ope\">" +
                    "<label onclick=\"edit(" + obj[i].Id + ")\">修改</label>&nbsp;" +
                    " <label onclick=\"del(" + obj[i].Id + ")\">删除</label>" +
                    "</div>" +
                    "</div>";
            }
            $("#list").html(str);
        });

    }

    function del(id) {
        if (confirm("你确定删除该图片吗？")) {
            $.post("@Url.Action("Del")",{id:id},function(row) {
                if (row > 0) {
                    getlist();
                } else {
                    alert("操作失败！");
                }
            });
        }
    }
    function edit(id) {
        location.href = "@Url.Action("window")/"+id;
    }
</script>